The Javascript Adventure by Ron Sims II

The Javascript Adventure by Ron Sims II

Author:Ron Sims II [Sims II, Ron]
Language: eng
Format: epub, azw3, pdf
ISBN: 9781329219939
Publisher: Lulu.com
Published: 2015-08-08T22:00:00+00:00


hearts--;

alert("You battled a Grublor and were hurt in the battle." +

" You lost a heart.");

We used a bit of Javascript magic to remove a heart. When you have a variable that contains a number you can add a double minus sign to the end of it to subtract one.

Note: If you add a double plus sign to the end of a variable that contains a number it will add one.

Try it out:

var test = 1;

test++;

alert(test);

The last if/else is very important. If the player still has hearts after a battle, you show screen two again. If the player's hearts are less than 1, then you show a game over message.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.